package test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class test {
    //大写字母
    static ArrayList<String> uppercaseList = new ArrayList<>();
    //小写字母
    static ArrayList<String> lowercaseList = new ArrayList<>();
    //数字
    static ArrayList<String> numberList = new ArrayList<>();
    //给大小写，数字集合赋值
    static {
        //大小写赋值
        for(int i = 0; i <=25; i++){
            char Big = (char)(65 + i);
            char Small = (char)(97 + i);
            uppercaseList.add(Big + "");
            lowercaseList.add(Small + "");
        }
        //数字赋值
        for(int i = 0; i <=9; i++){
            char number = (char)(48+i);
            numberList.add(number + "");
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //软件名字
        System.out.println("软件名字(首字母)：");
        String softwareName = sc.next();
        //是否需要特殊子符
        System.out.println("是否需要特殊字符(yes or no)：");
        String specialChar = sc.next();
        String password = initWord(softwareName,specialChar);
        System.out.println("生成的密码是：" + password);
    }
    /*生成密码*/
    public static String initWord(String softwareName, String specialChar){
        //1.密码变量
        StringBuilder code = new StringBuilder();
        code.append(softwareName);
        //2.创建集合---存放密码后面部分
        ArrayList<String> password = new ArrayList<>();
        //3.判断是否需要添加特殊字符，yes添加，其他不添加
        if(specialChar.equals("yes")){
            password.add("@");
        }
        //4.获取密码集合，打乱顺序
        //10位大小写数字密码 + "@"符号
        shuffleList(password);
        Collections.shuffle(password);

        //5.将集合转为字符串，装到code中
        String temp = password.toString().replace(", ","").replace("[","").replace("]","");
        code.append(temp);
        //返回值
        return code.toString();
    }
    /*
    * 参数：密码集合password
    * 功能：将获取的大小写字符或者数字放入password中
    * */
    public static void shuffleList(ArrayList<String> password){
        int big = 3;//大写3个字符
        int small = 2;//小写2个字符
        int  number = 5;//数字5个字符
        //获取大写
        for (int i = 0; i < big; i++) {
            Collections.shuffle(uppercaseList);
            password.add(uppercaseList.get(0));
        }
        //获取小写
        for (int i = 0; i < small; i++) {
            Collections.shuffle(lowercaseList);
            password.add(lowercaseList.get(0));
        }
        //获取数字
        for (int i = 0; i < number; i++) {
            Collections.shuffle(numberList);
            password.add(numberList.get(0));
        }








        String[] numberStr = {"0","1","2","3","4","5","6","7","8","9"};//数字字符
    }
}
